package com.dao;

import com.entity.Users;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDao {

    @Select("select * from users where username=#{username}")
    public Users selectByUsername(String username);

    @Select("select * from users where username=#{username} and password=#{password}")
    public Users selectByUsernameAndPassword(@Param("username")String username, @Param("password") String password);

    @Insert("insert into users (username,password,name,phone,address)"
    + "values (#{username},#{password},#{name},#{phone},#{address})")
    @SelectKey(keyProperty = "id",statement = "SELECT LAST_INSERT_ID()",before = false,resultType = Integer.class)
    public boolean insert(Users user);

    @Update("Update users set name=#{name},phone=#{phone},address=#{address} where id=#{id}")
    public boolean update(Users user);

    @Select("select * from users where id=#{id}")
    public Users select(int id);

    @Update("Update users set password=#{password} where id=#{id}")
    public boolean updatePassword(@Param("id") int id,@Param("password")String password);

    @Select("select * from users")
    public List<Users>  selectList();
}
